package com.itzdm.client.fallback;

import com.itzdm.client.client.WsClient;
import com.itzdm.client.domain.po.Message;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @作者：张德明
 * @时间：2025/4/6 12:53
 */
@Slf4j
public class WsFallback implements FallbackFactory<WsClient> {
    @Override
    public WsClient create(Throwable cause) {
        return new WsClient() {

            @Override
            public void sendMsg(Long userId, Message message) {
                log.info("sendMsg userId: {}, message: {}", userId, message);
                throw new RuntimeException(cause);
            }

            @Override
            public void sendMessage(Long friendId, String message) {
                log.info("sendMessage friendId: {}, message: {}", friendId, message);
                throw new RuntimeException(cause);
            }
        };
    }
}
